<%--
  Created by IntelliJ IDEA.
  User: Damon
  Date: 2018/4/22
  Time: 17:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery/jquery.min.js"></script>
    <script src="layui/layui.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
    <!--css类引用-->
    <link rel="stylesheet" href="page/style.css">
    <script type="text/javascript" src="page/demo.js.下载"></script>
</head>
<body  class="catbox">
<input type="hidden" id="ids"  value="<%=request.getParameter("ids")%>">

<table id="cartTable"  border="1">
    <thead>
    <tr>
        <th><label><input class="check-all check" type="checkbox">&nbsp;全选</label></th>
        <th>商品</th>
        <th>购买价格</th>
        <th>购买数量</th>
        <th>小计</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="test">


    </tbody>


</table>


<div class="foot" id="foot">
    <label class="fl select-all"><input type="checkbox" class="check-all check">&nbsp;全选</label>
    <a class="fl delete" id="deleteAll" href="javascript:;">删除</a>
    <div class="fr closing">结 算</div>
    <div class="fr total">合计：￥<span id="priceTotal">10</span></div>
    <div class="fr selected" id="selected">已选商品<span id="selectedTotal">15</span>件<span class="arrow up">︽</span><span class="arrow down">︾</span></div>
    <div class="selected-view">
        <div id="selectedViewList" class="clearfix"><span class="del" index="0">取消选择</span></div><div><span class="del" index="1">取消选择</span></div><div><span class="del" index="2">取消选择</span></div></div>
    <span class="arrow">◆<span>◆</span></span>
</div>
</div>

</div>
</div>

</div>


</body>

<script>

    $.ajax({
        url:"http://localhost:8088/user/queryShopCarbyid",
        data:{ids:$("#ids").val()},
        dataType:"json",
        async:false,
        type:"GET",
        success:function(data) {

            /*var  data = JSON.stringify(data);*/
        var  str  ="";
            for (var item in data) {
                console.log(item);//得到键
                for (var i = 0; i < data[item].length; i++) {
                    //通过 键得到相对应的值
                    json = JSON.stringify(data[item][i])
                    console.log(json);
                     json =  eval('('+json+ ')')
                    
                    str+=" <tr class=on><td class=checkbox><input name=names check type=checkbox></td>" +
                        "            <td class=goods><span>"+json.shopname+"</span></td>" +
                        "            <td class=price>"+json.price+"</td>" +
                        "            <td class=count><span class=reduce>-</span><input class=count-input type=text value="+json.shopcount+"><span class=add>+</span></td>" +
                        "            <td class=subtotal>"+json.shopcount*json.price+"</td>" +
                        "            <td class=operation><span class=delete>删除</span></td></tr>"

                }

                $("#test").html(str)
            }


        }


    })

     function  test(){

         var arr=document.getElementsByName("names");
         //arr是一个数组，就是所有checkbox的值；
         for(i=0;i<arr.length;i++) {
             if (arr[i].checked) {
                 alert(arr[i].value)
             }
         }


     }



</script>

</html>
